//
//  HomeTableViewCell.m
//  A_Project_DLS151129_SQ
//
//  Created by 151129-49宋强 on 16/1/20.
//  Copyright © 2016年 www.lanou3g.com蓝鸥. All rights reserved.
//

#import "HomeTableViewCell.h"

@implementation HomeTableViewCell

- (void)dealloc
{
    [_imgView release];
    [_xinLabel release];
    [_nameLabel release];
    [_xinLabel release];
    [_contentLabel release];
    [_titleLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        _imgView.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_imgView];
        [_imgView release];
        
        self.xinView = [[UIImageView alloc] init];
        _xinView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_xinView];
        [_xinView release];
        
        self.xinLabel = [[UILabel alloc] init];
        _xinLabel.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_xinLabel];
        [_xinLabel release];
        
        self.nameLabel = [[UILabel alloc] init];
        // _nameLabel.backgroundColor = [UIColor greenColor];
        _nameLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];
        
        self.contentLabel = [[UILabel alloc] init];
        // _contentLabel.backgroundColor = [UIColor blueColor];
        _contentLabel.numberOfLines = 0;
        [self.contentView addSubview:_contentLabel];
        [_contentLabel release];
        
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont boldSystemFontOfSize:20];
        // _titleLabel.backgroundColor = [UIColor redColor];
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        
    }
    return  self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _nameLabel.frame = CGRectMake(10, 10, 100, 20);
    _imgView.frame = CGRectMake(10, 10 + 20 + 10, 355, 150);
    CGFloat h = [[self class] heightWithText:_titleLabel.text];
    _titleLabel.frame = CGRectMake(10, 40 + 150 + 10, 355, h);
    CGFloat hh = [[self class] heightWithText:_contentLabel.text];
    _contentLabel.frame = CGRectMake(10, 200 + h + 10, 355, hh);
    
    
    
}
+ (CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName: [UIFont systemFontOfSize:17]};
    CGSize s = CGSizeMake(355, 1000);
    CGRect r = [text boundingRectWithSize:s options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return r.size.height;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
